package com.zx.map.dao.impl;

import com.zx.map.dao.CustAcctLogDao;
import com.zx.map.dao.mapper.CustAcctLogMapper;
import com.zx.map.dao.model.CustAcctLog;
import com.zx.map.dao.model.CustAcctLogExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 14-3-1
 * Time: 上午10:54
 * To change this template use File | Settings | File Templates.
 */
@Component("custAcctLogDao")
public class CustAcctLogImpl implements CustAcctLogDao {

    @Autowired
    private CustAcctLogMapper mapper;

    /**
     * 新增
     */
    public Integer add(CustAcctLog custAcctLog) throws DataAccessException {
        int column = mapper.insert(custAcctLog);
        if (column != 1) {
            throw new RuntimeException("");
        }
        return custAcctLog.getAcctId();
    }

    /**
     * 修改
     *
     * @param custAcctLog
     * @return
     * @throws org.springframework.dao.DataAccessException
     */
    public Integer update(CustAcctLog custAcctLog) throws DataAccessException {
        int column = mapper.updateByPrimaryKeySelective(custAcctLog);
        if (column != 1) {
            throw new RuntimeException("");
        }
        return custAcctLog.getAcctId();
    }

    /**
     * 删除
     */
    public void delete(CustAcctLog custAcctLog) throws DataAccessException {
        int column = mapper.deleteByPrimaryKey(custAcctLog.getAcctId());
        if (column != 1) {
            throw new RuntimeException("");
        }
    }

    /**
     *
     */
    public List<CustAcctLog> getListByExample(CustAcctLogExample example)
            throws DataAccessException {
        return mapper.selectByExample(example);
    }

    /**
     *
     */
    public int countListByExample(CustAcctLogExample example)
            throws DataAccessException {
        return mapper.countByExample(example);
    }

    /**
     * 根据筛选的记录 更新某个字段
     */
    public void updateByExample(CustAcctLog custAcctLog, CustAcctLogExample example)
            throws DataAccessException {
        mapper.updateByExampleSelective(custAcctLog, example);
    }

    /**
     * 分页查找
     */
    public List<CustAcctLog> getPageByExample(int pageSize, int pageBegin,
                                              CustAcctLogExample example) throws DataAccessException {
        return mapper.getPageByModel(pageSize, pageBegin, example);
    }
}
